package com.fr.chart;

import com.fr.base.Inter;
import com.fr.chart.axis.SeriesAttrAlpha;
import com.fr.chart.axis.SeriesAttrLine;
import com.fr.chart.axis.ValueAxis;
import com.fr.chart.legend.Legend;
import com.fr.chart.plot.Area3DPlot;
import com.fr.chart.plot.AreaPlot;
import com.fr.chart.plot.Bar2DPlot;
import com.fr.chart.plot.Bar3DPlot;
import com.fr.chart.plot.CustomAttr;
import com.fr.chart.plot.CustomPlot;
import com.fr.chart.plot.GanttPlot;
import com.fr.chart.plot.Line3DPlot;
import com.fr.chart.plot.LinePlot;
import com.fr.chart.plot.MeterPlot;
import com.fr.chart.plot.Pie3DPlot;
import com.fr.chart.plot.PiePlot;
import com.fr.chart.plot.Plot;
import com.fr.chart.plot.RadarPlot;
import com.fr.chart.plot.RangePlot;
import com.fr.chart.plot.SeriesAttr;
import com.fr.chart.plot.SeriesCollection;
import com.fr.chart.plot.StockPlot;
import com.fr.chart.plot.XYScatterPlot;
import java.awt.Color;
import java.text.DecimalFormat;

public abstract class ChartFactory
{
  public static String[] allChartNames = { Inter.getLocText("ChartF-Column"), Inter.getLocText("ChartF-Line"), Inter.getLocText("ChartF-Bar"), Inter.getLocText("ChartF-Pie"), Inter.getLocText("ChartF-Area"), Inter.getLocText("ChartF-XYScatter"), Inter.getLocText("ChartF-Radar"), Inter.getLocText("ChartF-Stock"), Inter.getLocText("ChartF-Meter"), Inter.getLocText("ChartF-Range_Chart"), Inter.getLocText("ChartF-Comb_Chart"), Inter.getLocText("ChartF-Gantt") };
  public static Chart[][] allChartTypes = { { createBar2DChart(false, false, false), createBar2DChart(false, true, false), createBar2DChart(false, true, true), createBar3DChart(false, false, false, false), createBar3DChart(false, false, false, true), createBar3DChart(false, true, false, false), createBar3DChart(false, true, true, false) }, { createLineChart(false, false, false), createLineChart(true, false, false), createLineChart(true, false, true), createLineChart(false, true, false), createLineChart(true, true, false), createLineChart(true, true, true), createLine3DChart() }, { createBar2DChart(true, false, false), createBar2DChart(true, true, false), createBar2DChart(true, true, true), createBar3DChart(true, false, false, false), createBar3DChart(true, false, false, true), createBar3DChart(true, true, false, false), createBar3DChart(true, true, true, false) }, { createPieChart(0), createPieChart(6), createPie3DChart(0), createPie3DChart(15) }, { createAreaChart(false, false), createAreaChart(true, false), createAreaChart(true, true), createArea3DChart(false, false), createArea3DChart(true, false), createArea3DChart(true, true) }, { createXYScatterChart(true, false), createXYScatterChart(true, true), createXYScatterChart(false, true) }, { createRadarChart(true, false, false), createRadarChart(true, true, false), createRadarChart(true, false, true), createRadarChart(true, true, true) }, { createStockChart(0), createStockChart(1), createStockChart(2), createStockChart(3) }, { createMeterChart() }, { createRangeChart() }, { createCustomChart() }, { createGanttChart() } };

  private static void setLegendRoundBorder(Plot paramPlot)
  {
    Legend localLegend = paramPlot.getLegend();
    if (localLegend != null)
    {
      localLegend.setRoundBorder(true);
      localLegend.setBorderStyle(1);
      localLegend.setBorderColor(Color.GRAY);
    }
  }

  public static Chart createBar2DChart(boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3)
  {
    Bar2DPlot localBar2DPlot = new Bar2DPlot();
    localBar2DPlot.setIsHorizontal(paramBoolean1);
    localBar2DPlot.setIsStacked(paramBoolean2);
    if (paramBoolean2)
      localBar2DPlot.setSeriesOverlapPercent(1.0D);
    if (paramBoolean3)
    {
      localBar2DPlot.getValueAxis().setPercentage(paramBoolean3);
      localBar2DPlot.getValueAxis().setFormat(new DecimalFormat("0%"));
    }
    else
    {
      localBar2DPlot.getValueAxis().setFormat(new DecimalFormat("0"));
    }
    localBar2DPlot.getValueAxis().setAxisShow(false);
    setLegendRoundBorder(localBar2DPlot);
    return new Chart(localBar2DPlot);
  }

  public static Chart createBar3DChart(boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3, boolean paramBoolean4)
  {
    Bar3DPlot localBar3DPlot = new Bar3DPlot();
    localBar3DPlot.setIsHorizontal(paramBoolean1);
    localBar3DPlot.setIsStacked(paramBoolean2);
    localBar3DPlot.setHorizontalDrawBar(paramBoolean4);
    if (paramBoolean4)
      localBar3DPlot.setSeriesOverlapPercent(-0.5D);
    else
      localBar3DPlot.setSeriesOverlapPercent(1.0D);
    if (paramBoolean3)
    {
      localBar3DPlot.getValueAxis().setPercentage(true);
      localBar3DPlot.getValueAxis().setFormat(new DecimalFormat("0%"));
    }
    else
    {
      localBar3DPlot.getValueAxis().setFormat(new DecimalFormat("0"));
    }
    setLegendRoundBorder(localBar3DPlot);
    return new Chart(localBar3DPlot);
  }

  public static Chart createPieChart(int paramInt)
  {
    PiePlot localPiePlot = new PiePlot();
    localPiePlot.setSeparatePercent(paramInt);
    setLegendRoundBorder(localPiePlot);
    return new Chart(localPiePlot);
  }

  public static Chart createPie3DChart(int paramInt)
  {
    Pie3DPlot localPie3DPlot = new Pie3DPlot();
    localPie3DPlot.setSeparatePercent(paramInt);
    setLegendRoundBorder(localPie3DPlot);
    return new Chart(localPie3DPlot);
  }

  public static Chart createLineChart(boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3)
  {
    LinePlot localLinePlot = new LinePlot();
    localLinePlot.setIsStacked(paramBoolean1);
    localLinePlot.setIsShowMarker(paramBoolean2);
    if (paramBoolean3)
    {
      localLinePlot.getValueAxis().setPercentage(true);
      localLinePlot.getValueAxis().setFormat(new DecimalFormat("0%"));
    }
    else
    {
      localLinePlot.getValueAxis().setFormat(new DecimalFormat("0"));
    }
    localLinePlot.getValueAxis().setAxisShow(false);
    setLegendRoundBorder(localLinePlot);
    return new Chart(localLinePlot);
  }

  public static Chart createLine3DChart()
  {
    Line3DPlot localLine3DPlot = new Line3DPlot();
    localLine3DPlot.getValueAxis().setFormat(new DecimalFormat("0"));
    setLegendRoundBorder(localLine3DPlot);
    return new Chart(localLine3DPlot);
  }

  public static Chart createCustomChart()
  {
    CustomPlot localCustomPlot = new CustomPlot();
    localCustomPlot.getValueAxis().setFormat(new DecimalFormat("0"));
    createSeriesMap4CustomPlot(localCustomPlot);
    setLegendRoundBorder(localCustomPlot);
    return new Chart(localCustomPlot);
  }

  public static Chart createAreaChart(boolean paramBoolean1, boolean paramBoolean2)
  {
    AreaPlot localAreaPlot = new AreaPlot();
    localAreaPlot.setIsStacked(paramBoolean1);
    if (paramBoolean2)
    {
      localAreaPlot.getValueAxis().setPercentage(true);
      localAreaPlot.getValueAxis().setFormat(new DecimalFormat("0%"));
    }
    else
    {
      localAreaPlot.getValueAxis().setFormat(new DecimalFormat("0"));
    }
    localAreaPlot.getValueAxis().setAxisShow(false);
    setLegendRoundBorder(localAreaPlot);
    return new Chart(localAreaPlot);
  }

  public static Chart createArea3DChart(boolean paramBoolean1, boolean paramBoolean2)
  {
    Area3DPlot localArea3DPlot = new Area3DPlot();
    localArea3DPlot.setIsStacked(paramBoolean1);
    if (paramBoolean2)
    {
      localArea3DPlot.getValueAxis().setPercentage(true);
      localArea3DPlot.getValueAxis().setFormat(new DecimalFormat("0%"));
    }
    else
    {
      localArea3DPlot.getValueAxis().setFormat(new DecimalFormat("0"));
    }
    setLegendRoundBorder(localArea3DPlot);
    return new Chart(localArea3DPlot);
  }

  public static Chart createMeterChart()
  {
    MeterPlot localMeterPlot = new MeterPlot();
    return new Chart(localMeterPlot);
  }

  public static Chart createRangeChart()
  {
    RangePlot localRangePlot = new RangePlot();
    localRangePlot.getValueAxis().setFormat(new DecimalFormat("0"));
    return new Chart(localRangePlot);
  }

  public static Chart createGanttChart()
  {
    GanttPlot localGanttPlot = new GanttPlot();
    setLegendRoundBorder(localGanttPlot);
    return new Chart(localGanttPlot);
  }

  public static Chart createXYScatterChart(boolean paramBoolean1, boolean paramBoolean2)
  {
    XYScatterPlot localXYScatterPlot = new XYScatterPlot();
    localXYScatterPlot.setShowMarker(paramBoolean1);
    localXYScatterPlot.setShowLine(paramBoolean2);
    localXYScatterPlot.getXAxis().setFormat(new DecimalFormat("0"));
    localXYScatterPlot.getYAxis().setFormat(new DecimalFormat("0"));
    setLegendRoundBorder(localXYScatterPlot);
    return new Chart(localXYScatterPlot);
  }

  public static Chart createRadarChart(boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3)
  {
    RadarPlot localRadarPlot = new RadarPlot();
    localRadarPlot.setShowLine(paramBoolean1);
    localRadarPlot.setShowMarker(paramBoolean2);
    localRadarPlot.setIsFilled(paramBoolean3);
    localRadarPlot.getSeriesCollection().getDefaultSeriesAttr().addCondition(new SeriesAttrAlpha(0.6F));
    SeriesAttr localSeriesAttr = new SeriesAttr();
    localSeriesAttr.addCondition(new SeriesAttrLine(com.fr.chart.core.ChartCoreConstants.CHART_COLOR_ARRAY[0], 2));
    localRadarPlot.getSeriesCollection().putSeriesAttr(0, localSeriesAttr);
    setLegendRoundBorder(localRadarPlot);
    return new Chart(localRadarPlot);
  }

  public static Chart createStockChart(int paramInt)
  {
    StockPlot localStockPlot = new StockPlot(paramInt);
    localStockPlot.getPriceAxis().setFormat(new DecimalFormat("0"));
    localStockPlot.getVolumeAxis().setFormat(new DecimalFormat("0"));
    setLegendRoundBorder(localStockPlot);
    return new Chart(localStockPlot);
  }

  public static void createSeriesMap4CustomPlot(Plot paramPlot)
  {
    SeriesCollection localSeriesCollection = paramPlot.getSeriesCollection();
    localSeriesCollection.setDefaultSeriesAttr(new CustomAttr());
    CustomAttr localCustomAttr1 = new CustomAttr(1);
    CustomAttr localCustomAttr2 = new CustomAttr(2);
    localSeriesCollection.putSeriesAttr(0, localCustomAttr1);
    localSeriesCollection.putSeriesAttr(1, localCustomAttr2);
  }
}